//
//  ViewController.m
//  04_Work
//
//  Created by dllo on 16/7/19.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "ViewController.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height


@interface ViewController ()
@property (nonatomic, strong) UIImageView *backImageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor whiteColor];
    self.backImageView = [[UIImageView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:self.backImageView];
    UIImage *backImage = [UIImage imageNamed:@"u=4120016548,4190929560&fm=23&gp=0.jpg"];
    [self.backImageView setImage:backImage];
    UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blur];
    effectView.frame = self.view.frame;
    [self.backImageView addSubview:effectView];
    
    UIView *clearView = [[UIView alloc] initWithFrame:self.view.frame];
    clearView.backgroundColor = [UIColor clearColor];
    [effectView addSubview:clearView];
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    backButton.frame = CGRectMake(30, 30, 60, 40);
    [backButton setBackgroundImage:[UIImage imageNamed:@"player_btn_close_normal"] forState:UIControlStateNormal];
    [self.view addSubview:backButton];
    
    UILabel *musicNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH / 2 - 30, 30, 60, 40)];
    musicNameLabel.text = @"十年";
    musicNameLabel.textAlignment = 1;
    musicNameLabel.font = [UIFont systemFontOfSize:22];
    musicNameLabel.textColor = [UIColor whiteColor];
    [clearView addSubview:musicNameLabel];
    
    UILabel *singerNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH / 2 - 60, 70, 120, 30)];
    singerNameLabel.text = @"一  陈奕迅  一";
    singerNameLabel.textAlignment = 1;
    singerNameLabel.font = [UIFont systemFontOfSize:19];
    singerNameLabel.textColor = [UIColor whiteColor];
    [clearView addSubview:singerNameLabel];
    
    UIButton *biaoZhunButton = [UIButton buttonWithType:UIButtonTypeSystem];
    biaoZhunButton.frame = CGRectMake(WIDTH / 2 - 100, 120, 60, 20);
    [biaoZhunButton setBackgroundImage:[UIImage imageNamed:@"player_btn_bz_sel_normal"] forState:UIControlStateNormal];
    [self.view addSubview:biaoZhunButton];
    
    UIButton *MVButton = [UIButton buttonWithType:UIButtonTypeSystem];
    MVButton.frame = CGRectMake(WIDTH / 2 - 18, 120, 50, 20);
    [MVButton setBackgroundImage:[UIImage imageNamed:@"player_btn_mv_normal@2x副本-1"] forState:UIControlStateNormal];
    [self.view addSubview:MVButton];

    UIButton *dtsButton = [UIButton buttonWithType:UIButtonTypeSystem];
    dtsButton.frame = CGRectMake(WIDTH / 2 + 50, 120, 50, 20);
    [dtsButton setBackgroundImage:[UIImage imageNamed:@"player_btn_dts_off"] forState:UIControlStateNormal];
    [self.view addSubview:dtsButton];
    
    UIImageView *roteImageView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 170, WIDTH - 100, WIDTH - 100)];
    roteImageView.backgroundColor = [UIColor redColor];
    roteImageView.layer.cornerRadius = (WIDTH - 100) / 2;
    roteImageView.layer.masksToBounds = YES;
    UIImage *roteImage = [UIImage imageNamed:@"u=1377413493,2194527414&fm=23&gp=0.jpg"];
    [roteImageView setImage:roteImage];
    [clearView addSubview:roteImageView];
    
    UILabel *musicLabel = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH / 2 - 80, WIDTH - 100 + 20 + 170, 160, 30)];
    musicLabel.textAlignment = 1;
    musicLabel.text = @"十年 － 陈奕迅";
    musicLabel.textColor = [UIColor whiteColor];
    [clearView addSubview:musicLabel];
    
    UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(50, WIDTH + 130, WIDTH - 100, 30)];
    [slider setValue:0 animated:YES];
    slider.minimumValue = 0;
    slider.maximumValue = 100;
    [slider setThumbImage:[UIImage imageNamed:@"player_slider_playback_thumb"] forState:UIControlStateNormal];
    [slider setMinimumTrackImage:[UIImage imageNamed:@"player_slider_playback_left"] forState:UIControlStateNormal];
    [slider setMaximumTrackImage:[UIImage imageNamed:@"player_slider_playback_right"] forState:UIControlStateNormal];
    [self.view addSubview:slider];
    
    UIButton *playButton = [UIButton buttonWithType:UIButtonTypeSystem];
    playButton.frame = CGRectMake(WIDTH / 2 - 50, WIDTH + 160, 100, 100);
    [playButton setBackgroundImage:[UIImage imageNamed:@"hp_player_btn_play_normal"] forState:UIControlStateNormal];
    [self.view addSubview:playButton];

    [playButton addTarget:self action:@selector(playSong:)  forControlEvents:UIControlEventTouchUpInside];
//    UIImageView *playRoteImageView = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH / 2 - 50, WIDTH + 160, 100, 100)];
//    playRoteImageView.layer.cornerRadius = 100 / 2;
//    playRoteImageView.layer.masksToBounds = YES;
//    UIImage *playRoteImage = [UIImage imageNamed:@"hp_player_btn_play_normal"];
//    [playRoteImageView setImage:playRoteImage];
//    [clearView addSubview:playRoteImageView];
    
    UIImageView *behindRoteImageView = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH / 2 - 135, WIDTH + 170, 80, 80)];
    behindRoteImageView.layer.cornerRadius = 100 / 2;
    behindRoteImageView.layer.masksToBounds = YES;
    UIImage *behindRoteImage = [UIImage imageNamed:@"hp_player_btn_pre_normal"];
    [behindRoteImageView setImage:behindRoteImage];
    [clearView addSubview:behindRoteImageView];
    
    UIImageView *beforeRoteImageView = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH / 2 + 55, WIDTH + 170, 80, 80)];
    beforeRoteImageView.layer.cornerRadius = 100 / 2;
    beforeRoteImageView.layer.masksToBounds = YES;
    UIImage *beforeRoteImage = [UIImage imageNamed:@"hp_player_btn_next_normal"];
    [beforeRoteImageView setImage:beforeRoteImage];
    [clearView addSubview:beforeRoteImageView];
    
    UIImageView *heartImageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, WIDTH + 250, 70, 70)];
    UIImage *heartImage = [UIImage imageNamed:@"player_btn_favorite_normal"];
    [heartImageView setImage:heartImage];
    [clearView addSubview:heartImageView];
    
    UIImageView *xunHuanImageView = [[UIImageView alloc] initWithFrame:CGRectMake(95, WIDTH + 250, 70, 70)];
    UIImage *xunHuanImage = [UIImage imageNamed:@"player_btn_repeat_normal"];
    [xunHuanImageView setImage:xunHuanImage];
    [clearView addSubview:xunHuanImageView];

    UIImageView *xiaZaiImageView = [[UIImageView alloc] initWithFrame:CGRectMake(170, WIDTH + 250, 70, 70)];
    UIImage *xiaZaiImage = [UIImage imageNamed:@"player_btn_download_normal"];
    [xiaZaiImageView setImage:xiaZaiImage];
    [clearView addSubview:xiaZaiImageView];
    
    UIImageView *shareImageView = [[UIImageView alloc] initWithFrame:CGRectMake(245, WIDTH + 250, 70, 70)];
    UIImage *shareImage = [UIImage imageNamed:@"player_btn_share_normal"];
    [shareImageView setImage:shareImage];
    [clearView addSubview:shareImageView];
    
    UIImageView *lieBiaoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(320, WIDTH + 250, 70, 70)];
    UIImage *lieBiaoImage = [UIImage imageNamed:@"player_btn_share_normal"];
    [lieBiaoImageView setImage:lieBiaoImage];
    [clearView addSubview:lieBiaoImageView];
    
}
// 暂停
- (void)pasueSong:(UIButton *)pasueSong {
    NSLog(@"暂停");
    [pasueSong removeTarget:self action:@selector(pasueSong:) forControlEvents:UIControlEventTouchUpInside];
    [pasueSong addTarget:self action:@selector(playSong:) forControlEvents:UIControlEventTouchUpInside];
    [pasueSong setImage:[UIImage imageNamed:@"hp_player_btn_pause_normal"] forState:UIControlStateNormal];
}

- (void)playSong:(UIButton *)playButton {
    NSLog(@"播放");
    // 移除点击事件
    [playButton removeTarget:self action:@selector(playSong:) forControlEvents:UIControlEventTouchUpInside];
    [playButton addTarget:self action:@selector(pasueSong:) forControlEvents:UIControlEventTouchUpInside];
    [playButton setImage:[UIImage imageNamed:@"hp_player_btn_play_normal"] forState:UIControlStateNormal];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
